<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
  <!-- Google tag (gtag.js) -->
  <script async src="https://www.googletagmanager.com/gtag/js?id=G-0ZJQN9ZQ47"></script>
  <script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-0ZJQN9ZQ47');
  </script>
  <meta charset="utf-8">
  <title>在 Windows 10 下安装 Wechaty &mdash; 褪色的抽象</title>
  <meta name="author" content="Kaffa">






  <!-- http://t.co/dKP3o1e -->
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, initial-scale=1">


    <link href="./favicon.ico" rel="icon">

  <link href="./theme/css/main.css" media="screen, projection"
        rel="stylesheet" type="text/css">
  <!--
  <link href="//fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic"
        rel="stylesheet" type="text/css">
  <link href="//fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic"
        rel="stylesheet" type="text/css">
  -->
</head>

<body>
  <header role="banner"><hgroup>
  <h1><a href="./"><span style="color:#52A2C6">褪</span>
<span style="color:#6791BC">色</span>
<span style="color:#7C80B2">的</span>
<span style="color:#916FA8">抽</span>
<span style="color:#A65E9E">象</span></a></h1>
    <h2>kaffa's blog</h2>
</hgroup></header>
  <nav role="navigation"><ul class="subscription" data-subscription="rss">
</ul>


<ul class="main-navigation">
    <li><a href="/">首页</a></li>
    <li><a href="/category/sui-bi.html">随笔</a></li>
    <li><a href="/category/yue-du.html">阅读</a></li>
    <li><a href="/category/ren-wen.html">人文</a></li>
    <li><a href="/category/zi-ran.html">自然</a></li>
    <li><a href="/category/ri-zhi.html">日志</a></li>
</ul></nav>
  <div id="main">
    <div id="content" class="bronze">
<div>
  <article class="hentry" role="article">
<header>
      <h1 class="entry-title">在 Windows 10 下安装 Wechaty</h1>
    <p class="meta">
<time datetime="2018-07-24T12:00:00+08:00" pubdate>2018-07-24 周二</time>    </p>
</header>

  <div class="entry-content"><div class="section" id="section-1">
<h2>介绍</h2>
<p><a class="reference external" href="https://github.com/Chatie/wechaty">Wechaty</a> 是一个对话机器人软件开发包，它可以帮你用 6 行 JavaScript 代码实现一个微信个人账号。由于使用 node 技术，它支持 Linux、Windows、macOS 平台和 Docker 容器。它的安装过程和其它 node 包类似，首先 <tt class="docutils literal">git clone</tt> 源代码，再使用 node 的 npm 命令 <tt class="docutils literal">npm install &amp; npm start</tt> 实现开箱即用，同时官方也提供了入门案例：<a class="reference external" href="https://github.com/Chatie/wechaty-getting-started">Wechaty getting started</a>。而在国内，实际安装过程中可能会因某些软件依赖的原因遇到问题，本文记录了安装过程中可能会出现的错误及解决办法，下面描述详细的步骤和说明：</p>
<div class="section" id="section-2">
<h3>概念</h3>
<dl class="docutils">
<dt><a class="reference external" href="https://github.com/Chatie/wechaty">Wechaty</a></dt>
<dd>项目地址</dd>
<dt><a class="reference external" href="https://github.com/Chatie/wechaty-getting-started">Wechaty Getting Started</a></dt>
<dd>Wechaty 起步</dd>
<dt><a class="reference external" href="https://chatie.io/wechaty/">Wechaty Documents</a></dt>
<dd>Wechaty 文档</dd>
<dt><a class="reference external" href="https://github.com/Chatie/wechaty/wiki/Puppet">Puppet</a></dt>
<dd>一个包含了机器人对话逻辑的抽象类，是 Wechaty 技术架构的一部分。继承实现 Puppet 抽象类（协议）的组件，即可实现更广泛的与联系人、消息/一对一对话、群组/聊天室/多对多对话等相关逻辑。Puppet 的中文是木偶，用在这里相当传神。</dd>
<dt><a class="reference external" href="https://www.npmjs.com/package/node-gyp">node-gyp</a></dt>
<dd>基于 gyp 编写的用来编译 node 本地扩展模块的 node 包，而 gpy 是 Chromium 项目上用于实现跨平台编译的工具。
安装文档：<a class="reference external" href="https://github.com/nodejs/node-gyp#installation">https://github.com/nodejs/node-gyp#installation</a></dd>
<dt><a class="reference external" href="https://www.npmjs.com/package/windows-build-tools">windows-build-tools</a></dt>
<dd>node 包装的 Windows 平台的编译工具
安装文档：<a class="reference external" href="https://github.com/felixrieseberg/windows-build-tools">https://github.com/felixrieseberg/windows-build-tools</a></dd>
<dt><a class="reference external" href="https://www.npmjs.com/package/node-expat">node-expat</a></dt>
<dd>基于 <a class="reference external" href="https://libexpat.github.io/">libexpat</a> 的用来处理 XML 的 node 包，libexpat 是一个号称最快的 XML 解析库，纯 C 语言编写。Wechaty 使用它解析基于 XML 的通讯。
安装文档：<a class="reference external" href="https://www.npmjs.com/package/node-expat">https://www.npmjs.com/package/node-expat</a></dd>
<dt><a class="reference external" href="https://www.python.org/downloads/">Python 2.7</a></dt>
<dd>一门愈久弥新的语言，node-gyp 的依赖 Python 2.7 实现跨平台编译</dd>
<dt><a class="reference external" href="https://github.com/GoogleChrome/puppeteer">puppeteer</a></dt>
<dd>可编程的 Google Chrome， Google Chrome 团队官方出品。</dd>
<dt><a class="reference external" href="https://www.chromium.org/">Chromium</a></dt>
<dd>puppeteer 依赖一个特定的 Chromium 版本，Chrome 就是 开源 Chromium + Google 开发的闭源的扩展包。</dd>
</dl>
</div>
<div class="section" id="section-3">
<h3>安装步骤</h3>
<ol class="arabic simple">
<li>下载 Wechaty 源代码</li>
<li>安装依赖，配置</li>
<li><tt class="docutils literal">npm install &amp; npm start</tt> 启动</li>
</ol>
</div>
</div>
<div class="section" id="section-4">
<h2>详细步骤</h2>
<ol class="arabic simple">
<li>下载 Wechaty 源代码</li>
</ol>
<p>首先我们建立源代码目录，本文使用 <tt class="docutils literal"><span class="pre">D:\code</span></tt>。如果你使用了其他目录，在后文中作相应的替换即可。
让我们从入门项目开始，运行以下命令下载，并进入项目目录:</p>
<pre class="literal-block">
git clone https://github.com/lijiarui/wechaty-getting-started.git
cd wechaty-getting-started
</pre>
<ol class="arabic simple" start="2">
<li>安装依赖</li>
</ol>
<p>首先安装 <strong>node-v10.x.x</strong>。在 Windows 下，推荐使用官方提供的安装包，截至本文最新 64 位系统安装包是：<a class="reference external" href="https://nodejs.org/dist/v10.7.0/node-v10.7.0-x64.msi">https://nodejs.org/dist/v10.7.0/node-v10.7.0-x64.msi</a>，如果网速不够，建议使用迅雷下载。</p>
<p>除了 node-v10 ，Wechaty 也依赖其它软件，而由于众所周知的网络原因，安装它们并不会太顺利。</p>
<p>此时，如果运行 <tt class="docutils literal">npm install &amp; npm start</tt>，会报以下错误:</p>
<pre class="literal-block">
Microsoft Windows [版本 10.0.16299.492]
(c) 2017 Microsoft Corporation。保留所有权利。


D:\code&gt;cd wechaty-getting-started

D:\code\wechaty-getting-started&gt;npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
added 134 packages from 94 contributors and audited 324 packages in 22.581s
found 0 vulnerabilities


D:\code\wechaty-getting-started&gt;npm start

&gt; wechaty-getting-started&#64;0.1.0 start D:\code\wechaty-getting-started
&gt; node examples/starter-bot.js

01:59:34 INFO Wechaty &lt;default&gt; start() v0.18.5 is starting...
01:59:34 INFO Wechaty initPuppet() using puppet: default
01:59:34 INFO PuppetConfig installPuppet(wechaty-puppet-puppeteer&#64;^0.4.2) please wait ...
npm:
&gt; node-expat&#64;2.3.16 install D:\code\wechaty-getting-started\node_modules\wechaty\node_modules\node-expat
&gt; node-gyp rebuild


npm:
D:\code\wechaty-getting-started\node_modules\wechaty\node_modules\node-expat&gt;if not defined npm_config_node_gyp (node &quot;D:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js&quot; rebuild )  else (node &quot;D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js&quot; rebuild )

npm: gyp
npm:  ERR! configure error
gyp ERR! stack Error: Can't find Python executable &quot;C:\Python36\python.EXE&quot;, you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.&lt;anonymous&gt; (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at D:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:158:21)
gyp ERR! System Windows_NT 10.0.16299

npm: gyp ERR! command &quot;D:\\Program Files\\nodejs\\node.exe&quot; &quot;D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js&quot; &quot;rebuild&quot;
gyp ERR! cwd D:\code\wechaty-getting-started\node_modules\wechaty\node_modules\node-expat
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

npm: npm WARN
npm:  wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of brolog&#64;^1.6.5 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of file-box&#64;^0.8.22 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of hot-import&#64;^0.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of lru-cache&#64;^4.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of qr-image&#64;^3.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of promise-retry&#64;^1.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rxjs&#64;^6.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rx-queue&#64;^0.4.26 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of state-switch&#64;^0.6.2 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of watchdog&#64;^0.8.10 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of wechaty-puppet&#64;^0.6.4 but none is installed. You must install peer dependencies yourself.


npm: npm ERR!
npm:  code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat&#64;2.3.16 install: `node-gyp rebuild`
npm ERR! Exit status 1

npm: npm ERR!
npm ERR! Failed at the node-expat&#64;2.3.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm:
npm
npm:  ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\username\AppData\Roaming\npm-cache\_logs\2018-07-22T17_59_53_633Z-debug.log

01:59:53 ERR PupptConfig puppetResolver(default) install fail: Command failed: npm install wechaty-puppet-puppeteer&#64;^0.4.2
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable &quot;C:\Python36\python.EXE&quot;, you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.&lt;anonymous&gt; (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at D:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:158:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command &quot;D:\\Program Files\\nodejs\\node.exe&quot; &quot;D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js&quot; &quot;rebuild&quot;
gyp ERR! cwd D:\code\wechaty-getting-started\node_modules\wechaty\node_modules\node-expat
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of brolog&#64;^1.6.5 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of file-box&#64;^0.8.22 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of hot-import&#64;^0.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of lru-cache&#64;^4.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of qr-image&#64;^3.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of promise-retry&#64;^1.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rxjs&#64;^6.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rx-queue&#64;^0.4.26 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of state-switch&#64;^0.6.2 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of watchdog&#64;^0.8.10 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of wechaty-puppet&#64;^0.6.4 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat&#64;2.3.16 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat&#64;2.3.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\username\AppData\Roaming\npm-cache\_logs\2018-07-22T17_59_53_633Z-debug.log

{ Error: Command failed: npm install wechaty-puppet-puppeteer&#64;^0.4.2
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable &quot;C:\Python36\python.EXE&quot;, you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.&lt;anonymous&gt; (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at D:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:158:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command &quot;D:\\Program Files\\nodejs\\node.exe&quot; &quot;D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js&quot; &quot;rebuild&quot;
gyp ERR! cwd D:\code\wechaty-getting-started\node_modules\wechaty\node_modules\node-expat
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of brolog&#64;^1.6.5 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of file-box&#64;^0.8.22 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of hot-import&#64;^0.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of lru-cache&#64;^4.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of qr-image&#64;^3.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of promise-retry&#64;^1.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rxjs&#64;^6.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rx-queue&#64;^0.4.26 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of state-switch&#64;^0.6.2 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of watchdog&#64;^0.8.10 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of wechaty-puppet&#64;^0.6.4 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat&#64;2.3.16 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat&#64;2.3.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\username\AppData\Roaming\npm-cache\_logs\2018-07-22T17_59_53_633Z-debug.log

    at ChildProcess.exithandler (child_process.js:291:12)
    at ChildProcess.emit (events.js:182:13)
    at ChildProcess.EventEmitter.emit (domain.js:442:20)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
killed: false,
code: 1,
signal: null,
cmd: 'npm install wechaty-puppet-puppeteer&#64;^0.4.2 ' }
01:59:53 ERR Wechaty start() exception: Command failed: npm install wechaty-puppet-puppeteer&#64;^0.4.2
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable &quot;C:\Python36\python.EXE&quot;, you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.&lt;anonymous&gt; (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at D:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:158:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command &quot;D:\\Program Files\\nodejs\\node.exe&quot; &quot;D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js&quot; &quot;rebuild&quot;
gyp ERR! cwd D:\code\wechaty-getting-started\node_modules\wechaty\node_modules\node-expat
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of brolog&#64;^1.6.5 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of file-box&#64;^0.8.22 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of hot-import&#64;^0.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of lru-cache&#64;^4.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of qr-image&#64;^3.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of promise-retry&#64;^1.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rxjs&#64;^6.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rx-queue&#64;^0.4.26 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of state-switch&#64;^0.6.2 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of watchdog&#64;^0.8.10 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of wechaty-puppet&#64;^0.6.4 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat&#64;2.3.16 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat&#64;2.3.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\username\AppData\Roaming\npm-cache\_logs\2018-07-22T17_59_53_633Z-debug.log

{ Error: Command failed: npm install wechaty-puppet-puppeteer&#64;^0.4.2
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable &quot;C:\Python36\python.EXE&quot;, you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.&lt;anonymous&gt; (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at D:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:158:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command &quot;D:\\Program Files\\nodejs\\node.exe&quot; &quot;D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js&quot; &quot;rebuild&quot;
gyp ERR! cwd D:\code\wechaty-getting-started\node_modules\wechaty\node_modules\node-expat
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of brolog&#64;^1.6.5 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of file-box&#64;^0.8.22 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of hot-import&#64;^0.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of lru-cache&#64;^4.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of qr-image&#64;^3.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of promise-retry&#64;^1.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rxjs&#64;^6.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of rx-queue&#64;^0.4.26 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of state-switch&#64;^0.6.2 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of watchdog&#64;^0.8.10 but none is installed. You must install peer dependencies yourself.
npm WARN wechaty-puppet-puppeteer&#64;0.4.2 requires a peer of wechaty-puppet&#64;^0.6.4 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat&#64;2.3.16 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat&#64;2.3.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\username\AppData\Roaming\npm-cache\_logs\2018-07-22T17_59_53_633Z-debug.log

    at ChildProcess.exithandler (child_process.js:291:12)
    at ChildProcess.emit (events.js:182:13)
    at ChildProcess.EventEmitter.emit (domain.js:442:20)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
killed: false,
code: 1,
signal: null,
cmd: 'npm install wechaty-puppet-puppeteer&#64;^0.4.2 ' }

D:\code\wechaty-getting-started&gt;
</pre>
<p>通过阅读上述日志，分析依赖关系如下:</p>
<pre class="literal-block">
wechaty-puppet-puppeteer --&gt; node-expat --&gt; node-gyp --&gt; gyp --&gt; Python 2.7 &amp; Windows Build Tools
</pre>
<p>所以，接下来要做的就是一一从依赖的最底层安装</p>
<ol class="arabic simple">
<li>安装 <a class="reference external" href="https://www.python.org/downloads/">Python 2.7</a> 至 <tt class="docutils literal"><span class="pre">C:\Python27\python.exe</span></tt>，设置环境变量 <tt class="docutils literal"><span class="pre">PYTHON=C:\Python27\python.exe</span></tt></li>
</ol>
<p>注意 node-gyp 并不支持 Python 3.x，如果你安装了 Python 3.x，错误日志如下:</p>
<pre class="literal-block">
Can't find Python executable &quot;C:\Python36\python.EXE&quot;, you can set the PYTHON env variable.
</pre>
<p>你可能会疑惑这个本来存在的 Python 3 路径，个人认为这个不准确错误提示可以算入 npm 包的 Bug</p>
<ol class="arabic simple" start="2">
<li>安装 <a class="reference external" href="https://www.npmjs.com/package/windows-build-tools">windows-build-tools</a></li>
</ol>
<p>参考 windows-build-tools 官方文档，有以下两种方式:</p>
<pre class="literal-block">
1.Visual C++ Build Tools
2.Visual Studio 2017 / Visual Studio 2015
</pre>
<p>我这里由于已经安装 Visual Studio 2017 社区版，所以没有尝试其他选项。这里的关键是需要一个 VC++ 编译器来编译 Windows 本地程序。选项1在微软官方地址已失效，不容易找到，npm 官方推荐了安装 Visual Studio 2015。
安装结束后，可以使用 <tt class="docutils literal">npm install <span class="pre">node-expat</span></tt> 验证上述安装配置是否成功</p>
<ol class="arabic simple" start="3">
<li>安装 <a class="reference external" href="https://github.com/GoogleChrome/puppeteer">puppeteer</a></li>
</ol>
<p>由于网络原因，puppeteer 依赖的 <a class="reference external" href="https://www.chromium.org/">Chromium</a> 并不能顺利安装。此时，我们可以借助一个阿里巴巴公司提供的 <a class="reference external" href="https://npm.taobao.org/">cnpm</a> 特色工具安装:</p>
<pre class="literal-block">
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install puppeteer
</pre>
<p>如果你遇到 <tt class="docutils literal">Chromium revision is not downloaded.</tt> 时，在解决办法中看到的设置 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD 其实是一个误导，
这个选项并不能帮助你安装 puppeteer，而是让你在更新时不必每次都下载 Chromium 二进制。</p>
<p>PS: 这里还有一个手动安装办法，但不推荐：可以手动下载 chromium 安装包，放在 /node_modules/puppeteer/.local-chromium/ 下，例如:</p>
<pre class="literal-block">
D:\code\wechaty-getting-started\node_modules\_puppeteer&#64;1.6.0&#64;puppeteer\.local-chromium\win64-571375
</pre>
<p>这个地址在 macOS 上如下，其中的数字可能不同:</p>
<pre class="literal-block">
~/node_modules/puppeteer/.local-chromium/mac-526987/chrome-mac
</pre>
<ol class="arabic simple" start="4">
<li>.NET Framework 4.5.1 [仅 Windows Vista / 7 需要]</li>
</ol>
<p>如果 Windows Vista / 7 版本，则需要手动安装 .Net Framework</p>
<ol class="arabic" start="5">
<li><p class="first">如果使用的是 PadChat 组件的 Wechaty，且已有相应 token 则还需要设置以下几个环境变量:</p>
<pre class="literal-block">
WECHATY_LOG=silly
WECHATY_PUPPET=padchat
WECHATY_PUPPET_PADCHAT_TOKEN=*YOUR-TOKEN*
</pre>
</li>
<li><p class="first">至此，应该可以顺利运行起步项目:</p>
<pre class="literal-block">
npm install &amp; npm start
</pre>
</li>
<li><p class="first">运行后，程序会在控制台窗口打开一个文本的二维码，在二维码下方是该二维码的网址。</p>
</li>
</ol>
<p>如果你对扫描控制台的文本二维码遇到问题，可以参考我的 <a class="reference external" href="https://kaffa.im/a-story-about-text-qrcode.html">一篇关于二维码的博文</a>。</p>
</div>
<div class="section" id="section-5">
<h2>总结</h2>
<p>由于已成功启动项目，所以我并没有在 Windows 7 系统 或 32 位机上进行配置，主要问题应该差不多。
解决办法基本上一一查阅上述出现错误的软件的文档，应该可以独立解决。</p>
<p>当然，如果你遇到了任何其他问题，也欢迎 <a class="reference external" href="https://github.com/kaffa">我的Github</a> 上联系我。</p>
<p>感谢阅读。</p>
</div>
</div>
    <footer>
<p class="meta">
  <span class="byline author vcard">
    发布人： <span class="fn">
        Kaffa
    </span>
  </span>
<time datetime="2018-07-24T12:00:00+08:00" pubdate>2018-07-24 周二</time>  <span class="categories">
    <a class='category' href='./category/sui-bi.html'>随笔</a>
  </span>
  <span class="categories">
    <a class="category" href="./tag/sui-bi.html">随笔</a>,    <a class="category" href="./tag/essays.html">Essays</a>,    <a class="category" href="./tag/ji-zhu.html">技术</a>,    <a class="category" href="./tag/technology.html">Technology</a>,    <a class="category" href="./tag/wechaty.html">Wechaty</a>,    <a class="category" href="./tag/node.html">Node</a>,    <a class="category" href="./tag/nodejs.html">Node.js</a>,    <a class="category" href="./tag/open-source.html">Open Source</a>  </span>
</p><div class="sharing">
</div>    </footer>
    <div id="gitalk-container"></div>
  </article>

</div>

<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<script>
  var gitalk = new Gitalk({
    clientID: '47c6091c4039fb3df197',
    clientSecret: '8ed206e3b86fb7a90a0dd78d4ed3425d7384b45a',
    repo: 'kaffa.github.io',
    owner: 'kaffa',
    admin: ['kaffa'],
    id: location.pathname.substr(0, 50),
    distractionFreeMode: false
  });
  gitalk.render('gitalk-container');
</script>

<aside class="sidebar">
  <section>
    <h1>最近博文</h1>
    <ul id="recent_posts">
      <li class="post">
          <a href="./hario-mss-1b-mss-1r-16.html">手摇磨豆器-HARIO-MSS-1B-MSS-1R-16-的 12 个零件</a>
      </li>
      <li class="post">
          <a href="./article-39-chapter-iv-of-labor-contract-law-of-China-and-buber-and-drip-bag-coffee.html">公司为什么会选择违法解除劳动合同、包焙儿和挂耳咖啡</a>
      </li>
      <li class="post">
          <a href="./review-2022.html">2022 回顾</a>
      </li>
      <li class="post">
          <a href="./things-in-the-past-half-year-of-2022.html">2022H2半年小记</a>
      </li>
      <li class="post">
          <a href="./alaunch-your-first-productivity-software.html">ALaunch第一个生产力工具</a>
      </li>
    </ul>
  </section>
  <section>

    <h1>分类</h1>
    <ul id="recent_posts">
        <li><a href="./category/ren-wen.html">人文</a></li>
        <li><a href="./category/ri-zhi.html">日志</a></li>
        <li><a href="./category/sui-bi.html">随笔</a></li>
        <li><a href="./category/yue-du.html">阅读</a></li>
        <li><a href="./category/zi-ran.html">自然</a></li>
    </ul>
  </section>

  <section>
  <h1>标签</h1>
    <a href="./tag/sui-bi.html">随笔</a>,    <a href="./tag/essays.html">Essays</a>,    <a href="./tag/ka-pei.html">咖啡</a>,    <a href="./tag/mo-dou-qi.html">磨豆器</a>,    <a href="./tag/hario.html">Hario</a>,    <a href="./tag/ren-sheng.html">人生</a>,    <a href="./tag/life.html">Life</a>,    <a href="./tag/bao-bei-er.html">包焙儿</a>,    <a href="./tag/yue-du.html">阅读</a>,    <a href="./tag/reading.html">Reading</a>,    <a href="./tag/ruan-jian.html">软件</a>,    <a href="./tag/software.html">Software</a>,    <a href="./tag/ji-zhu.html">技术</a>,    <a href="./tag/technology.html">Technology</a>,    <a href="./tag/alaunch.html">ALaunch</a>,    <a href="./tag/productive.html">Productive</a>,    <a href="./tag/bo-ke.html">博客</a>,    <a href="./tag/my-blog.html">My Blog</a>,    <a href="./tag/gitee-pages.html">Gitee Pages</a>,    <a href="./tag/playwright.html">PlayWright</a>,    <a href="./tag/gong-zuo-guan.html">工作观</a>,    <a href="./tag/view-of-work.html">view-of-work</a>,    <a href="./tag/cat.html">Cat</a>,    <a href="./tag/mao.html">猫</a>,    <a href="./tag/wang-wen.html">网文</a>,    <a href="./tag/dian-shi-ju.html">电视剧</a>,    <a href="./tag/ke-bi-bu-lai-en-te.html">科比·布莱恩特</a>,    <a href="./tag/kobe-bryant.html">Kobe Bryant</a>,    <a href="./tag/luo-shan-ji-zao-chen-si-dian.html">洛杉矶早晨四点</a>,    <a href="./tag/los-angeles-morning-4am.html">Los Angeles Morning 4AM</a>,    <a href="./tag/markdown.html">Markdown</a>,    <a href="./tag/markdown-grammar.html">Markdown Grammar</a>,    <a href="./tag/mkdocs.html">MkDocs</a>,    <a href="./tag/hugo.html">Hugo</a>,    <a href="./tag/resume.html">Résumé</a>,    <a href="./tag/fan-qie-gong-zuo-fa.html">番茄工作法</a>,    <a href="./tag/pomodoro-technique.html">Pomodoro Technique</a>,    <a href="./tag/fan-qie-zhong.html">番茄钟</a>,    <a href="./tag/pomodoro-clock.html">Pomodoro Clock</a>,    <a href="./tag/semantic-ui.html">Semantic-UI</a>,    <a href="./tag/nodejs.html">nodejs</a>,    <a href="./tag/pplusplus.html">PPlusPlus</a>,    <a href="./tag/faq.html">FAQ</a>,    <a href="./tag/zeev-suraski.html">Zeev Suraski</a>,    <a href="./tag/internals.html">internals@</a>,    <a href="./tag/php.html">PHP</a>,    <a href="./tag/p.html">P++</a>,    <a href="./tag/rasmus-lerdorf.html">Rasmus Lerdorf</a>,    <a href="./tag/pplusplus-faq.html">PPlusPlus FAQ</a>,    <a href="./tag/microsoft-designer-mouse.html">Microsoft Designer Mouse</a>,    <a href="./tag/linux-distributions.html">Linux Distributions</a>,    <a href="./tag/arch-linux.html">Arch Linux</a>,    <a href="./tag/centos.html">CentOS</a>,    <a href="./tag/debian.html">Debian</a>,    <a href="./tag/elementary-os.html">Elementary OS</a>,    <a href="./tag/fedora.html">Fedora</a>,    <a href="./tag/freebsd.html">FreeBSD</a>,    <a href="./tag/gentoo.html">Gentoo</a>,    <a href="./tag/linux-from-scratch.html">Linux From Scratch</a>,    <a href="./tag/linux-mint.html">Linux Mint</a>,    <a href="./tag/netbsd.html">NetBSD</a>,    <a href="./tag/opensuse.html">openSuse</a>,    <a href="./tag/red-hat-enterprise-linux.html">Red Hat Enterprise Linux</a>,    <a href="./tag/slackware.html">Slackware</a>,    <a href="./tag/ubuntu.html">Ubuntu</a>,    <a href="./tag/restructuretext.html">reStructureText</a>,    <a href="./tag/restructuredtext-grammar.html">reStructuredText Grammar</a>,    <a href="./tag/vscode-extension.html">VSCode Extension</a>,    <a href="./tag/vsce.html">vsce</a>,    <a href="./tag/visual-studio-marketplace.html">Visual Studio Marketplace</a>,    <a href="./tag/macos.html">macOS</a>,    <a href="./tag/mac-os.html">Mac OS</a>,    <a href="./tag/macos-history.html">macOS History</a>,    <a href="./tag/machintosh.html">Machintosh</a>,    <a href="./tag/beos.html">BeOS</a>,    <a href="./tag/next.html">NeXT</a>,    <a href="./tag/openstep.html">OPENSTEP</a>,    <a href="./tag/mach.html">Mach</a>,    <a href="./tag/ren-wen.html">人文</a>,    <a href="./tag/humanity.html">Humanity</a>,    <a href="./tag/luo-ji-xue.html">逻辑学</a>,    <a href="./tag/logic.html">Logic</a>,    <a href="./tag/ke-ji-suan-xing.html">可计算性</a>,    <a href="./tag/shi-wu.html">事物</a>,    <a href="./tag/shi-jian.html">事件</a>,    <a href="./tag/shi-shi.html">事实</a>,    <a href="./tag/guan-nian.html">观念</a>,    <a href="./tag/ming-ti.html">命题</a>,    <a href="./tag/duan-yan.html">断言</a>,    <a href="./tag/yan-yi.html">演绎</a>,    <a href="./tag/gui-na.html">归纳</a>,    <a href="./tag/san-duan-lun.html">三段论</a>,    <a href="./tag/tong-yi-lu.html">同一律</a>,    <a href="./tag/pai-zhong-lu.html">排中律</a>,    <a href="./tag/yin-guo-lu.html">因果律</a>,    <a href="./tag/mao-dun-lu.html">矛盾律</a>,    <a href="./tag/zi-ran.html">自然</a>,    <a href="./tag/natural-science.html">Natural Science</a>,    <a href="./tag/xiong-ji-diao.html">胸棘鲷</a>,    <a href="./tag/orange-roughy.html">Orange Roughy</a>,    <a href="./tag/chang-shou-yu.html">长寿鱼</a>,    <a href="./tag/hua-shi-ren-lei-xue.html">化石人类学</a>,    <a href="./tag/gu-ren-lei-xue.html">古人类学</a>,    <a href="./tag/zhi-ren.html">智人</a>,    <a href="./tag/homo-sapiens.html">Homo sapiens</a>,    <a href="./tag/ni-an-de-te-ren.html">尼安德特人</a>,    <a href="./tag/homo.html">Homo</a>,    <a href="./tag/neanderthals.html">Neanderthals</a>,    <a href="./tag/sheng-zhi-ge-chi.html">生殖隔离</a>,    <a href="./tag/ji-yin-ce-xu.html">基因测序</a>,    <a href="./tag/ji-suan-ji-ke-xue.html">计算机科学</a>,    <a href="./tag/computer-science.html">Computer Science</a>,    <a href="./tag/dian-zi-gong-cheng.html">电子工程</a>,    <a href="./tag/electronic-engineering.html">Electronic Engineering</a>,    <a href="./tag/ruan-jian-gong-cheng-xue.html">软件工程学</a>,    <a href="./tag/software-engineering.html">Software Engineering</a>,    <a href="./tag/xin-xi-ji-zhu.html">信息技术</a>,    <a href="./tag/information-technology.html">Information Technology</a>,    <a href="./tag/geetest.html">GeeTest</a>,    <a href="./tag/windows.html">Windows</a>,    <a href="./tag/linux.html">Linux</a>,    <a href="./tag/jekyll.html">Jekyll</a>,    <a href="./tag/ruby.html">Ruby</a>,    <a href="./tag/msys2.html">MSYS2</a>,    <a href="./tag/vibora.html">Vibora</a>,    <a href="./tag/cygwin.html">Cygwin</a>,    <a href="./tag/mingw.html">MinGW</a>,    <a href="./tag/virtualpc.html">Virtualpc</a>,    <a href="./tag/vmware.html">VMWare</a>,    <a href="./tag/docker.html">Docker</a>,    <a href="./tag/msys.html">MSYS</a>,    <a href="./tag/msysgit.html">msysgit</a>,    <a href="./tag/pelican.html">Pelican</a>,    <a href="./tag/gitalk.html">Gitalk</a>,    <a href="./tag/gitment.html">Gitment</a>,    <a href="./tag/pelican-octopress-theme.html">Pelican Octopress Theme</a>,    <a href="./tag/pelican-octopress-theme-cn.html">pelican-octopress-theme-cn</a>,    <a href="./tag/node.html">Node</a>,    <a href="./tag/path.html">Path</a>,    <a href="./tag/psychology.html">Psychology</a>,    <a href="./tag/philosophy.html">Philosophy</a>,    <a href="./tag/nwjs.html">NW.js</a>,    <a href="./tag/electron.html">Electron</a>,    <a href="./tag/qrcode.html">QRCode</a>,    <a href="./tag/text-qrcode.html">Text QRCode</a>,    <a href="./tag/wechaty.html">Wechaty</a>,    <a href="./tag/open-source.html">Open Source</a>,    <a href="./tag/vscode.html">VSCode</a>,    <a href="./tag/linux-kernel.html">Linux Kernel</a>,    <a href="./tag/data.html">Data</a>,    <a href="./tag/information.html">Information</a>,    <a href="./tag/restructuredtext.html">reStructuredText</a>,    <a href="./tag/rst.html">rst</a>,    <a href="./tag/blog.html">Blog</a>,    <a href="./tag/zi-ding-yi-yu-ming.html">自定义域名</a>,    <a href="./tag/custom-domain.html">Custom Domain</a>,    <a href="./tag/github-pages.html">GitHub Pages</a>,    <a href="./tag/cname.html">CNAME</a>,    <a href="./tag/ji-zhu-zhi-shi-fen-lei.html">技术知识分类</a>,    <a href="./tag/technology-category.html">Technology Category</a>,    <a href="./tag/wen-ti-jie-jue.html">问题解决</a>,    <a href="./tag/problem-solving.html">Problem Solving</a>,    <a href="./tag/biao-ji-yu-yan.html">标记语言</a>,    <a href="./tag/octopress.html">octopress</a>,    <a href="./tag/asciidoc.html">AsciiDoc</a>  </section>


    <section>
        <h1>社区</h1>
        <ul>
            <li><a href="https://github.com/kaffa" target="_blank">My GitHub</a></li>
        </ul>
    </section>
    <section>
        <h1>链接</h1>
        <ul>
            <li><a href="http://paulgraham.com" target="_blank">Paul Graham</a></li>
            <li><a href="https://gvanrossum.github.io/" target="_blank">Guido van Rossum</a></li>
            <li><a href="https://kaffa.im" target="_blank">Kaffa</a></li>
            <li><a href="https://coffees.app" target="_blank">Coffee's</a></li>
            <li><a href="https://lundao.pub/" target="_blank">论道</a></li>
        </ul>
    </section>

</aside>    </div>
  </div>
  <footer role="contentinfo"><p>
    版权所有 &copy;  2018&ndash;2023  Kaffa &mdash;
  <span class="credit">自豪地采用 <a href="http://getpelican.com">Pelican</a> 技术</span>
</p></footer>
  <script src="./theme/js/modernizr-2.0.js"></script>
  <script src="./theme/js/ender.js"></script>
  <script src="./theme/js/octopress.js" type="text/javascript"></script>
  
</body>
</html>